<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String PATH = request.getContextPath();
%>

<jsp:include page="../common/header.jsp">
	<jsp:param name="title" value="通知公告"/>
</jsp:include>

<div class="page with-sidebar">
	<div class="page-header">
        <div class="page-header-content">
            <h1 style="width:500px">通知公告<small>案例</small></h1>
            <a class="back-button big page-back" href="<%=PATH %>"></a>
        </div>
    </div>
    
    <div class="page-sidebar">
    	<ul>
    		<li class="sticker sticker-color-orangeDark">
    			<a href="#touse">使用说明</a>
    		</li>
			<li class="sticker sticker-color-yellow">
    			<a href="#add">新增通知公告</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#list">查看通知公告</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#delete">删除通知公告</a>
    		</li>
    	</ul>
    </div>
    
    <div class="page-region">
    	<div class="grid" style="padding-left:20px;">
    		<div class="row">
				   <h2 id="touse">使用说明</h2>
				   <div>
				   		1. 这里的任何操作都是以JSON格式返回结果数据<br />
				   		2. 通知公告不能再次编辑，只能删除<br />
						3. 普通职员不能发布“通知公告”
				   </div>
    		</div>
    		<br />
			
    		<div class="row">
  				  <h2 id="add">新增通知公告</h2>
				  <div class="hero-unit">
					1.标题不能为空<br />
					2.内容不能为空
				  </div>
  				  <div>
  				  	<form action="<%=PATH %>/notify/add.htm" method="post">
  				  		<div class="row">
  				  			<h4 class="span2">公告标题：</h4>
							<div class="input-control text span7">
								<input type="text" name="notify.title" placeholder="公告的标题..."/>
							</div>
  				  		</div>
						
						<div class="row">
  				  			<h4 class="span2">公告内容：</h4>
							<div class="input-control textarea span7">
								<textarea name="notify.message"></textarea>
							</div>
  				  		</div>
						
						<div class="row">
							<input type="submit" class="big place-right bg-color-pink" value="保存"/>
						</div>
  				  	</form>
  				  </div>
    		</div>
			<br />
			
			<div class="row">
				<h2 id="list">查看通知公告</h2>
				
				<div class="">
					返回数据样例：<br />
					<pre class="prettyprint linenums prettyprinted">
{
	"data":1,
	"error":false,
	"message":[{"cellPhone":"18076556349","department":{"id":1,"name":"销售部"},
			  "id":1,"joinDate":1375381051000,"name":"集成显卡","password":"24f9356fe100863f8b108d476aa4f9bc",
			  "position":4,"unable":false}]
}
					</pre>
					其中data表示总共搜索到的职员数<br />
					message是搜索结果的JSON数据集<br /><br />
				</div>
				
				<div class="grid">
					<div class="row">
						<div>
							<h4 class="span1">第</h4>
							<input id="page" type="text" class="span1"/>
							<h4 class="span2">页，每页显示</h4>
							<input id="pageSize" type="text" class="span1"/>
							<h4 class="span1">条</h4>
						</div>
					</div>
					
					<div class="row">
						<button class="big place-right bg-color-blue" onclick="search();">浏览</button>
						<a href="#" id="search_a_list" target="_blank" class="big place-right" style="display:none;">
							<span id="search_list">搜索</span>
						</a>
					</div>
				</div>
			</div>
			<br />
			
			<div class="row">
  				  <h2 id="delete">删除通知公告</h2>
				  <div class="hero-unit">
					1.输入对应通知公告的id就可以删除了
				  </div>
  				  <div class="grid">
  				  	<div class="row">
						<h4 class="span2">公告id:</h4>
						<div class="input-control text span7">
							<input id="key" type="text" placeholder="id必须是数字且大于0..." />
						</div>
					</div>
					
					<div class="row">
						<button class="big place-right bg-color-blue" onclick="deleteNotify();">删除</button>
						<a href="#" id="search_a" target="_blank" class="big place-right" style="display:none;">
							<span id="search_span">搜索</span>
						</a>
					</div>
  				  </div>
    		</div>
			
    	</div>
    </div>
</div>

<script>
	function deleteNotify(){
		var key = $("#key").val();
		
		if(Number(key) > 0){
			if(confirm("真的要删除这条公告吗？")){
				$("#search_a").attr("href", "<%=PATH %>/notify/delete.htm?id="+key);
				$("#search_span").trigger("click");
			}
			
		}else{
			alert("输入有误！id必须是数字且大于0");
		}
		return true;
	}
	
	function search(){
		var page = $("#page").val();
		var size = $("#pageSize").val();
		$("#search_a_list").attr("href", "<%=PATH %>/notify/list.htm?page="+page+"&pageSize="+size);
		$("#search_list").trigger("click");
		
		return true;
	}
</script>

<%@ include file="../common/footer.jsp" %>